package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.UserService;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public User login(String username, String password, Integer userType) {
        QueryWrapper<User> query = new QueryWrapper<>();
        query.eq("username", username)
                .eq("password", password)
                .eq("user_type", userType)
                .eq("status", 1); // 只允许启用状态用户登录

        return this.getOne(query);
    }
}
